#ifndef _A_GAME__COMM__LIMIT_RESOURCES_MANAGER_H_
#define _A_GAME__COMM__LIMIT_RESOURCES_MANAGER_H_

#include <stdint.h>

#ifdef __cplusplus
extern "C" {
#endif

#define INVALIDATE_ID ((int )-1)
typedef int resid_t;

struct ResourcesOperation {
	//called by create lrm
	void * (*alloc)(void * ctx);

	//called by destory lrm
	void (*free)(void * res, void * ctx);

	//called by alloc resources
	int (*init)(resid_t res_id, void * res, void * init_data, void * ctx);

	//call by  release resources
	void (*destory)(resid_t res_id, void * res, void * ctx);
};

////////////////////////////////////////////////////////////////////////////////
//
//resid_t create_resources_manager(int max, 
//		struct resources_opt * opt, 
//		void * ctx);
//void destory_resources_manager(resid_t manager_id);
//
//resid_t alloc_resource(resid_t manager_id, void * init_data);
//void release_resources(resid_t manager_id, resid_t resource_id);
//
//void * get_resources(resid_t manager_id, resid_t resources_id);
//void * set_resources(resid_t manager_id, resid_t resources_id, void * res);

////////////////////////////////////////////////////////////////////////////////

int LRMStartup(int max_resources_type);
void LRMCleanup();

resid_t LRMCreate(int max_resources, struct ResourcesOperation * opt, void * ctx);
void    LRMDestory(resid_t lrm_id);

resid_t LRMAllocResources(resid_t lrm_id, void * ctx);
resid_t LRMAllocResourcesById(resid_t lrm_id, int id, void * ctx);
void    LRMReleaseResources(resid_t lrm_id, resid_t res_id);

void *  LRMGetResources(resid_t lrm_id, resid_t res_id);
void *  LRMSetResources(resid_t lrm_id, resid_t res_id, void * res);

#ifdef __cplusplus
}
#endif

#endif
